#include "BinarySearchTree.h"
#include <iostream>
using namespace std;

void test1()
{
	BSTree<int> t;
	int a[] = { 5,9,8,0,2,4 };
	for (auto e : a)
	{
		t.insert(e);
	}
	t.inorder();
	BSTreeNode<int>* ret = t.find(5);
	if(ret)
		cout << ret->_key << endl;
	ret = t.find(7);
	if (ret)
		cout << ret->_key << endl;
}

void test2()
{
	BSTree<int> t;
	int a[] = { 8,3,1,10,6,4,7,14,13 };
	for (auto e : a)
	{
		t.insert(e);
	}
	t.levelorder();
	cout << endl;
	t.erase(8);
	t.erase(3);
	t.erase(1);
	t.erase(7);
	t.levelorder();
	cout << endl;

}

void test3()
{
	BSTree<int> t1, t2;
	int a[] = { 8,3,1,10,6,4,7,14,13 };
	for (auto e : a)
	{
		t1.insert(e);
	}
	t1.levelorder();
	cout << endl;

	t1.erase(6);
	BSTree<int> t3 = t1;
	t3.levelorder();
	cout << endl;

	t3.erase(14);
	t2 = t3;
	t2.levelorder();
}

void test4()
{
	BSTree<int> t;
	int a[] = { 8,3,1,10,6,4,7,14,13 };
	for (auto e : a)
	{
		t.insertR(e);
	}
	t.levelorder();
	//cout << endl;
	//t.eraseR(8);
	//t.eraseR(3);
	//t.eraseR(1);
	//t.eraseR(7);

	for (auto e : a)
	{
		t.eraseR(e);
	}
	t.levelorder();
	cout << endl;
}
int main()
{
	test1();
	return 0;
}